package com.example.data.holidays;

import com.example.data.leave.Leave;

import org.springframework.jdbc.core.RowMapper;
import java.sql.ResultSet;
import java.sql.SQLException;

public class HolidaysDO extends Holidays implements RowMapper<Holidays> {
    public HolidaysDO(){
        super();
    }
    public static Holidays convert(Holidays holidays){
        Holidays holidaysInfo = new HolidaysDO();
        holidaysInfo.setEmpID(holidays.getEmpID());
        holidaysInfo.setAvailableHolidays(holidays.getAvailableHolidays());
        holidaysInfo.setRestHolidays(holidays.getRestHolidays());
        return holidaysInfo;
    }
    @Override
    public Holidays mapRow(ResultSet rs, int i) throws SQLException {
        Holidays holidaysDo = new HolidaysDO();
        holidaysDo.setEmpID(rs.getLong("empId"));
        holidaysDo.setAvailableHolidays(rs.getInt("availableHolidays"));// does it need to change into integer
        holidaysDo.setRestHolidays(rs.getInt("restHolidays"));
        return holidaysDo;
    }
}
